package com.twu.biblioteca;

import com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression;
import sun.misc.Regexp;

/**
 * Created with IntelliJ IDEA.
 * User: Joe
 * Date: 8/07/13
 * Time: 12:18 PM
 * To change this template use File | Settings | File Templates.
 */
public final class Movie {

    public final int movieID;
    public final String name;
    public final String year;
    public final String director;
    public final String rating;

    public Movie(int movieID, String name, String year, String director, String rating)
    {
        this.movieID = movieID;
        this.name = name;
        this.year = year;
        this.director = director;

        RegularExpression validRatingsRegEx = new RegularExpression("^([0-9]|10)$");

        if(validRatingsRegEx.matches(rating))
            this.rating = rating;
        else if(rating.isEmpty())
            this.rating ="N/A";
        else
            this.rating ="?";
    }

    @Override
    public String toString()
    {
        return String.format("%-25s %-5s %-25s %-6s", this.name, this.year, this.director, this.rating);
    }
}
